perm filename LECT19.TEX[ARK,TEX] blob sn#766845 filedate 1984-08-23 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	% copyright 1984 by Arthur Keller ... All rights reserved
C00009 00003	\section*{Assignment}
C00010 ENDMK
CāŠ—;
% copyright 1984 by Arthur Keller ... All rights reserved
\chapter{Tables}

%Fri, August 24

%2-3pm
%Tables
%>halign

%3-4pm
%<lab assignment 14>

Suppose that we do not want to take the trouble to figure out what the
widest entry in each column is going to be.
(Given that the widths of characters differ, this would not be a trivial
task.)
We can instead use the command \cmd{halign} to create a table
automatically, with \TeX\ doing the work of deciding how wide each column
should be.

Constructing a table using the \cmd{halign} command is actually quite
similar to the \cmd{tabset} command, in that it consists of a template,
followed by a series of {\sl row specifications}, each of which defines
the contents of one row of the table.
Recall the following table from Chapter~?.

\smallskip

\halign{#\hfil\quad&#\hfil\cr
Month&Weather\cr
May&Chance of Rain\cr
December&Snow\cr}

\smallskip

For example, for to set the above table using an \cmd{halign},
we would give the following commands:

\smallskip\noindent{\tt
\bs halign\lb\#\bs hfil\bs quad\&\#\hfil\bs cr\hfil\break
Month\&Weather\bs cr\hfil\break
May\&Chance of Rain\bs cr\hfil\break
December\&Snow\bs cr\rb}

\smallskip

Notice the {\tt\#} symbols in the first row of the \cmd{halign}.
They work very much like the {\tt \#1}, {\tt \#2}, etc., symbols that we
saw in the definition of macros with parameters, except that the {\tt\#}
sign is used alone here without a number.
In setting the table, \TeX\ automatically creates an \cmd{hbox} for each
column which is as wide as the widest entry in that column, and then
substitutes the text in each row specification for the corresponding
{\tt\#}.
As with the templates defined using the \cmd{settabs} command, we can
change the way entries in the table are printed by modifying the template
accordingly.
For example, to have entries in the table be flush right in each column,
we would insert an \cmd{hfil} before each {\tt\#}.

Suppose that we wanted the entire table to be centered on the width of the
page, with space above it and below it.
This turns out to be exactly how display math mode typesets equations, so
we can achieve the desired effect by putting {\tt\$\$} before and after
the \cmd{halign}.
Well, almost\dots.
It turns out that this does not work unless you first put the entire
\cmd{halign} inside of a \cmd{vbox}.
So, we need to say

\smallskip
\noindent
{\tt\$\$\bs vbox\lb\bs halign\lb{\sl template}\bs cr\hfil\break
{\sl row specification}\bs cr\hfil\break
{\sl row specification}\bs cr\hfil\break\rb\rb\$\$}

\smallskip

If we are using \cmd{halign} to typeset a table, we cannot use
\cmd{smallskip} to put space between the header and the first line of
ordinary entries.
Instead, we have to specify \cmd{noalign\lb\bs smallskip\rb}.
The \cmd{noalign} is used to specify that the material is to go
in between rows (in vertical mode) and it not part of a row.
As before, to get individual entries set in boldface, we must specify
\cmd{bf} in each column, since the effect of the \cmd{bf} command is
terminated at the end of the \cmd{hbox} enclosing each column.

If we wanted a black rule across the width of the table, we could say


\par\smallskip\noindent
\cmd{noalign\lb\bs smallskip\bs hrule\bs smallskip\rb}
\par\smallskip\noindent
where the \cmd{hrule} produces the horizontal rule.
In general, \cmd{hrule} and \cmd{vrule} produce horizontal and vertical
rules, respectively, 0.4 points wide, to the extent of the enclosing
horizontal or vertical box.
Working with rules can be rather tricky, since \TeX\ throws away the space
it would otherwise place between boxes when you ask for rules.

\bigskip

``The only thing that never looks right is a rule.
There is not in existence a page with a rule on it
that cannot be instantly and obviously improved
by taking the rule out.''

\rightline{--George Bernard Shaw, in {\sl The Dolphin\/} (1940).}

\section*{Assignment}

Reading for this lecture:
The {\sl \TeX book}, Chapter~22.

Assignment for this lecture:
To be provided later.